﻿using Brilliant_see.App;
using CommunityToolkit.Maui;
using Microsoft.Extensions.Logging;

namespace Brilliant_see.UI;

public static class MauiProgram
{
    public static MauiApp CreateMauiApp()
    {
        var builder = MauiApp.CreateBuilder();
        builder
            .UseMauiApp<App>()
            .UseMauiCommunityToolkit()
            .ConfigureFonts(fonts =>
            {
                fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
                fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
            })
            .RegisterAppServices()
            .RegisterViews();

#if DEBUG
        builder.Logging.AddDebug();
#endif

        return builder.Build();
    }

    public static MauiAppBuilder RegisterAppServices(this MauiAppBuilder mauiAppBuilder)
    {
        mauiAppBuilder.Services.AddAppServices();

        return mauiAppBuilder;
    }

    public static MauiAppBuilder RegisterViews(this MauiAppBuilder mauiAppBuilder)
    {
        mauiAppBuilder.Services.AddSingleton<Views.FavoritePage>();
        mauiAppBuilder.Services.AddSingleton<Views.HistoryPage>();

        mauiAppBuilder.Services.AddTransient<Views.SearchPage>();
        mauiAppBuilder.Services.AddTransient<Views.ComicBrowsePage>();

        return mauiAppBuilder;
    }
}